define(["jquery", "easy-admin"], function ($, ea) {

    var init = {
        pk: 'branch_id',
        table_elem: '#currentTable',
        table_render_id: 'currentTableRenderId',
        index_url: 'system.branch/index',
        add_url: 'system.branch/add',
        edit_url: 'system.branch/edit',
        delete_url: 'system.branch/delete',
        export_url: 'system.branch/jsExport',
        modify_url: 'system.branch/modify',
    };

    var Controller = {

        index: function () {
            ea.table.render({
                init: init,
                toolbar: ['refresh', 'add', 'export'],
                cols: [[
                    {type: 'checkbox'},
                    {field: 'branch_id', title: 'ID'},
                    {field: 'name', title: '网点名称', edit: "text"},
                    {field: 'brief', title: '简介', edit: "text"},
                    {field: 'sort', title: '排序', edit: 'text'},
                    {
                        width: 250, title: '操作', templet: ea.table.tool, operate: [
                            [{
                                class: 'layui-btn layui-btn-success layui-btn-xs',
                                method: 'open',
                                field: init.pk,
                                icon: '',
                                text: '编辑',
                                title: '编辑信息',
                                auth: 'edit',
                                url: init.edit_url,
                                extend: "",
                            },
                                {
                                    method: 'get',
                                    field: init.pk,
                                    icon: '',
                                    title: '确定删除？',
                                    text: '删除',
                                    url: init.delete_url,
                                    auth: 'delete',
                                    class: 'layui-btn layui-btn-danger layui-btn-xs',
                                    br: true,
                                },
                            ],
                        ]
                    },
                ]],
            });

            ea.listen();
        },
        add: function () {
            ea.listen();
        },
        edit: function () {
            ea.listen();
        },
    };
    return Controller;
});